package edu.mit.media.fv.aqview
{
	import edu.mit.media.fv.blocks.*;
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	import edu.mit.media.fv.aqwidgets.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	
	public class AQGroupViewer extends AQViewer
	{
		var _nameLabel:AQTextField
		var _volumeLabel:AQTextField
		var _balanceLabel:AQTextField
		var _qualityLabel:AQTextField
		var _goodButton:DisplayObject;
		var _badButton:DisplayObject;
		var _deleteButton:DisplayObject;
		var _okayButton:DisplayObject;
		
		
		private var group:GroupModel;
		
		public function AQGroupViewer(){
			super();
			FluidEventHandler.addEventListener(DisplayEvent.OPEN_GROUP, displayWidget);
		}
		
		public function displayWidget(event:DisplayEvent):void{
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WIDGET, this, "Voice"));
			
			this._nameLabel.text = event.name;
			this._volumeLabel.text = event.volume.toString();
			this._balanceLabel.text = event.balance.toString();
			if(event.quality){
				this._qualityLabel.text = "Good";
			}else{
				this._qualityLabel.text = "Bad";
			}
			this.id = event.id;
			this.group = GroupModel(Model.getModel(id));
			
		}
		public function processOkay(event:MouseEvent):void{
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WORKSPACE));
			this.group.name = this._nameLabel.text;
			this.group.updateInstances();
			
			var data:Object = new Object();
			data.command = FluidConstants.REQUEST_RENAME_GROUP;
			data.id = this.id;
			data.label = this._nameLabel.text;
			var e:FVNetworkEvent = new FVNetworkEvent(data);
			FluidEventHandler.dispatchEvent(e);
		
		}

	}
}